import Vue from 'vue'
import Router from 'vue-router'


const routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error)
};
const originalReplace = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
    return originalReplace.call(this, location).catch(err => err);
};

Vue.use(Router);

const createRouter = () => new Router({
    // mode 用于去除地址中的 # history  === 部署时改为hash
    mode: 'hash',
    // scrollBehavior 用于定义路由切换时，页面滚动。
    scrollBehavior: () => ({
        y: 0
    }),
    routes: [
        {
            path: '/index',
            name: 'Index',
            component: () => import('@/components/index')
        }
    ]
});
const router = createRouter();
export default router;

